package sse.ustc.cc.activity;

import java.util.ArrayList;

import sse.ustc.cc.base.TabBase;
import sse.ustc.cc.db.DBService;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class DayEntryAty extends TabBase implements OnClickListener {

	private Class<?> activities[] = {DayClassInfoAty.class, FileAty.class, CourseAty.class, LoginAty.class};
	private Button[] btn = new Button[4];
	private int currentSelect;
	private ArrayList<String> courseList;// 获取课程信息

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		setContainer(R.id.fl_container);
		//获取屏幕分辨率
		 DisplayMetrics dm = new DisplayMetrics();
		 getWindowManager().getDefaultDisplay().getMetrics(dm);
		 Log.e("dayentry-heght:",dm.heightPixels+"");
		Log.e("dayentry-wight:",dm.widthPixels+"");
		 
		courseList = new ArrayList<String>();// 课程列表声明
		DBService ds = new DBService(this);
		courseList = ds.selectCourse();// 选择课表信息，存放在list里面
		if(courseList.size()==0){
			ds.insertMsg();
		}else{
			
		}
		Log.e("firstdslfjkldsjf",courseList.size()+"");
		//ds.insertMsg();
		btn[0] = (Button) findViewById(R.id.btn_one);
		btn[0].setOnClickListener(this);
		btn[1] = (Button) findViewById(R.id.btn_two);
		btn[1].setOnClickListener(this);
		btn[2] = (Button) findViewById(R.id.btn_three);
		btn[2].setOnClickListener(this);
		btn[3] = (Button) findViewById(R.id.btn_four);
		btn[3].setOnClickListener(this);
		showActivity(activities[0]);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		btn[currentSelect].setBackgroundResource(R.color.darkslategray);
		switch (v.getId()) {
		case R.id.btn_one:
			currentSelect = 0;
			btn[0].setBackgroundResource(R.color.blue);
			showActivity(activities[0]);
			break;
		case R.id.btn_two:
			currentSelect = 1;
	
			btn[1].setBackgroundResource(R.color.blue);
			showActivity(activities[1]);
			break;
		case R.id.btn_three:
			currentSelect = 2;
			btn[2].setBackgroundResource(R.color.blue);
			showActivity(activities[2]);
			break;
		case R.id.btn_four:
			currentSelect = 3;
			btn[3].setBackgroundResource(R.color.blue);
			showActivity(activities[3]);
			break;
		}
	}
}
